var t = getApp();

Page({
    data: {
        active: 0,
        delbox: !1,
        id: wx.getStorageSync("yz_uid")
    },
    onLoad: function(t) {
        this.getStatus(), this.getData();
    },
    sdel: function(t) {
        var a = t.currentTarget.dataset.ind, e = this.data.datas;
        console.log(!e[a].edit_active), e[a].edit_active = !e[a].edit_active, this.setData({
            datas: e
        });
    },
    gobianji: function(t) {
        console.log(t.currentTarget.dataset.good);
        var a = t.currentTarget.dataset.good;
        wx.navigateTo({
            url: "/packageD/auction/auctioneer-publish/publish_first/publish_first?good=" + a
        });
    },
    toUp: function(a) {
        var e = this, i = {
            art: "upperLower",
            goods_id: a.currentTarget.dataset.good,
            status: 0 == a.currentTarget.dataset.status ? 1 : 0
        }, n = t.getNetAddresss("plugin.auction.api.index.getAuctionData");
        t._getNetWork({
            url: n,
            data: i,
            success: function(t) {
                var a = t.data;
                1 == a.result ? (wx.showToast({
                    title: a.data.upperLower,
                    icon: "none",
                    duration: 1e3
                }), e.getSearch()) : wx.showToast({
                    title: a.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    commodityDelete: function(a) {
        var e = this, i = a.currentTarget.dataset.good, n = t.getNetAddresss("plugin.auction.api.index.getAuctionData"), o = {
            goods_id: i,
            art: "delGoods"
        };
        wx.showModal({
            title: "提示",
            content: "此操作将永久删除该拍品, 是否继续? ",
            success: function(a) {
                a.confirm ? t._getNetWork({
                    url: n,
                    data: o,
                    success: function(t) {
                        var a = t.data;
                        1 == a.result ? (wx.showToast({
                            title: "拍品删除成功",
                            icon: "none",
                            duration: 1e3
                        }), e.getSearch()) : wx.showToast({
                            title: a.msg,
                            icon: "none",
                            duration: 1e3
                        });
                    },
                    fail: function(t) {
                        console.log(t);
                    }
                }) : a.cancel && console.log("用户点击取消");
            }
        });
    },
    emptyEditActive: function() {
        for (var t = 0; t < this.data.datas.length; t++) this.data.datas[t].edit_active = !1;
        this.setData({
            datas: this.data.datas
        });
    },
    itemClick: function(t) {
        console.log(t), this.setData({
            active: t.detail.index
        }), this.getSearch();
    },
    goFabu: function() {
        console.log(this.data.uncertified_status), "已认证" != this.data.renzhen_status && "2" == this.data.uncertified_status ? wx.showToast({
            title: "未认证会员不允许发布拍品",
            icon: "none",
            duration: 1e3
        }) : this.getNum();
    },
    getNum: function() {
        var a = this, e = t.getNetAddresss("plugin.auction.api.index.getAuctionData");
        t._getNetWork({
            url: e,
            data: {
                art: "judgeNum"
            },
            success: function(t) {
                1 == t.data.result ? wx.navigateTo({
                    url: "/packageD/auction/auctioneer-publish/publish_first/publish_first"
                }) : a.getverifyGoods();
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getverifyGoods: function() {
        var a = this, e = t.getNetAddresss("plugin.auction.api.index.getAuctionData");
        t._getNetWork({
            url: e,
            data: {
                art: "judgeNum2"
            },
            success: function(t) {
                var e = t.data;
                1 == e.result ? (console.log(a.data.renzhen_status), "未认证" == a.data.renzhen_status ? wx.navigateTo({
                    url: "/packageD/auction/auction-apply/auction-apply/auction-apply"
                }) : "认证中" == a.data.renzhen_status && wx.navigateTo({
                    url: "/packageD/auction/auction-apply/auction-apply/auction-apply?info=get"
                })) : (console.log(e, "需要购买指定商品才能申请"), wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1e3,
                    success: function() {
                        setTimeout(function() {
                            var t;
                            t = a.isString(e.data.judgeNum2) ? e.data.judgeNum2.url : e.data.judgeNum2, wx.navigateTo({
                                url: "/packageA/detail_v2/detail_v2?id=" + t
                            });
                        }, 1e3);
                    }
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getData: function() {
        var a = this, e = t.getNetAddresss("plugin.auction.api.index.getAuctionData");
        t._getNetWork({
            url: e,
            data: {
                art: "auctioneer"
            },
            success: function(t) {
                var e = t.data;
                1 == e.result ? a.setData({
                    info: e.data.auctioneer,
                    renzhen_status: e.data.auctioneer.status
                }) : wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    onReady: function() {},
    onShow: function() {
        this.getSearch();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareTimeline: function() {
        this.data.current_page >= this.data.last_page && wx.showToast({
            title: "暂无更多",
            icon: "none",
            duration: 1e3
        });
    },
    onShareAppMessage: function() {
        this.data.current_page >= this.data.last_page && wx.showToast({
            title: "暂无更多",
            icon: "none",
            duration: 1e3
        });
    },
    getStatus: function() {
        var a = this, e = t.getNetAddresss("plugin.auction.api.index.getAuctionData"), i = {
            member_id: a.data.id
        };
        t._getNetWork({
            url: e,
            data: i,
            success: function(t) {
                var e = t.data;
                1 == e.result ? (a.setData({
                    status: e.data.getVerify.status,
                    uncertified_status: e.data.getAgreement.uncertified_status,
                    is_release_switch: e.data.getAgreement.is_release_switch
                }), a.getSearch()) : wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getSearch: function() {
        var a, e = this;
        "0" == this.data.active ? a = t.getNetAddresss("plugin.auction.api.auction.check") : "1" == this.data.active ? a = t.getNetAddresss("plugin.auction.api.auction.biding") : "2" == this.data.active ? a = t.getNetAddresss("plugin.auction.api.auction.bid") : "3" == this.data.active ? a = t.getNetAddresss("plugin.auction.api.auction.finish") : "4" == this.data.active && (a = t.getNetAddresss("plugin.auction.api.auction.bid"));
        var i = {
            auctioneer_id: e.data.id
        };
        t._postNetWork({
            url: a,
            data: i,
            success: function(t) {
                var a = t.data;
                if (1 == a.result) {
                    for (var i = 0; i < a.data.data.length; i++) a.data.data[i].edit_active = !1;
                    e.setData({
                        datas: a.data.data,
                        current_page: a.data.data.current_page,
                        last_page: a.data.data.last_page,
                        total: a.data.total
                    }), console.log(e.data.datas);
                } else wx.showToast({
                    title: a.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});